package jp.tkym.labs.gwt.client.table;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertThat;

import org.junit.Test;


public class FlexTableBindAssert {
	@Test
	public void testFlexTableBindModel001(){
		FlexTableBindModel model = new FlexTableBindModel();
		model.allocateByRowIndex(3);
		assertThat(model.sources().size(), equalTo(4));
		assertThat(model.sources().get(0).size(), equalTo(0));
		assertThat(model.sources().get(1).size(), equalTo(0));
		assertThat(model.sources().get(2).size(), equalTo(0));
		assertThat(model.sources().get(3).size(), equalTo(0));
	}

	@Test
	public void testFlexTableBindModel002(){
		FlexTableBindModel model = new FlexTableBindModel();
		model.allocateByRowIndex(3);
		model.allocateByRowIndex(2);
		model.allocateByRowIndex(1);
		assertThat(model.sources().size(), equalTo(4));
		assertThat(model.sources().get(0).size(), equalTo(0));
		assertThat(model.sources().get(1).size(), equalTo(0));
		assertThat(model.sources().get(2).size(), equalTo(0));
		assertThat(model.sources().get(3).size(), equalTo(0));
	}
	
	@Test
	public void testFlexTableBindModel003(){
		FlexTableBindModel model = new FlexTableBindModel();
		model.allocateByRowIndex(0);
		assertThat(model.sources().size(), equalTo(1));
	}
	
	@Test
	public void testFlexTableBindModel004(){
		FlexTableBindModel model = new FlexTableBindModel();
		model.allocate(3, 3);
		model.allocate(3, 1);
		assertThat(model.sources().size(), equalTo(4));
		assertThat(model.sources().get(0).size(), equalTo(0));
		assertThat(model.sources().get(1).size(), equalTo(0));
		assertThat(model.sources().get(2).size(), equalTo(0));
		assertThat(model.sources().get(3).size(), equalTo(4));
	}

	@Test
	public void testFlexTableBindModel005(){
		FlexTableBindModel model = new FlexTableBindModel();
		FlexTableBindSource a = new FlexTableBindSource(null);
		FlexTableBindSource b = new FlexTableBindSource(null);
		model.setBindSource(3, 3, a);
		model.setBindSource(3, 1, b);
		assertThat(model.sources().size(), equalTo(4));
		assertThat(model.sources().get(0).size(), equalTo(0));
		assertThat(model.sources().get(1).size(), equalTo(0));
		assertThat(model.sources().get(2).size(), equalTo(0));
		assertThat(model.sources().get(3).size(), equalTo(4));
		assertThat(model.getBindSource(3, 3), sameInstance(a));
		assertThat(model.getBindSource(3, 1), sameInstance(b));
	}

	@Test
	public void testFlexTableBindModel006(){
		FlexTableBindModel model = new FlexTableBindModel();
		FlexTableBindSource a = new FlexTableBindSource(null);
		FlexTableBindSource b = new FlexTableBindSource(null);
		model.setBindSource(3, 3, a);
		model.setBindSource(3, 1, b);
		model.fill();
		assertThat(model.sources().size(), equalTo(4));
		assertThat(model.sources().get(0).size(), equalTo(4));
		assertThat(model.sources().get(1).size(), equalTo(4));
		assertThat(model.sources().get(2).size(), equalTo(4));
		assertThat(model.sources().get(3).size(), equalTo(4));
		assertThat(model.getBindSource(3, 3), sameInstance(a));
		assertThat(model.getBindSource(3, 1), sameInstance(b));
	}
	
//	@Test
//	public void testFlexTableBindModel007(){
//		FlexTableBindModel model = new FlexTableBindModel();
//		model.invalidIndex(1, 2);
//		assertThat(model.isInvalid(1, 2), is(true));
//		assertThat(model.isInvalid(0, 0), is(false));
//	}
}
